//
//  YHYcommenTableViewCell.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/29.
//
//

#import "YHYcommenTableViewCell.h"

@interface YHYcommenTableViewCell ()
@property (nonatomic,strong)UIImageView *starImaegView;
@end

@implementation YHYcommenTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    
    return self;
}
- (void)creatView{
    
    UIView *line = [UIView new];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
        make.height.mas_equalTo(0.4);
//        make.width.mas_equalTo(kScreenW);
        make.left.mas_offset(15 * AUTO_WIDTH);
        make.right.mas_offset(0);
        
    }];
    line.backgroundColor = HS;
    
    
    
    _leftTitleL = [UILabel new];

    [self.contentView addSubview:_leftTitleL];
    [_leftTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerYWithinMargins.mas_equalTo(self.contentView);
        make.left.mas_equalTo(15 * AUTO_WIDTH);
       
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
        
    }];
  
//    _leftTitleL.text = @"qqe";
    _leftTitleL.textColor = [UIColor blackColor];
    _leftTitleL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_HEIGHT];
    
    
    [self textL];
 }


- (UILabel *)textL{
    if(_textL == nil) {
        _textL = [[UILabel alloc] init];
        [self.contentView addSubview:_textL];
        [_textL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerYWithinMargins.mas_equalTo(self.contentView);
            make.centerXWithinMargins.mas_equalTo(self.contentView);
            
            make.height.mas_equalTo(15 * AUTO_HEIGHT);
            
            
        }];
//        _textL.text = @"aaaa";
        _textL.textColor = HS;
        _textL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_WIDTH];
    }
    return _textL;
}
- (UIImageView *)starImaegView{
    if (_starImaegView == nil) {
        _starImaegView = [UIImageView new];
        [self.contentView addSubview:_starImaegView];
        [_starImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15 * AUTO_WIDTH);
            make.height.mas_equalTo(15 * AUTO_HEIGHT);
            make.width.mas_equalTo(15 * AUTO_WIDTH);
            make.centerYWithinMargins.mas_equalTo(self.contentView);
        }];
        _starImaegView.backgroundColor = [UIColor redColor];
    }
    return _starImaegView;
}

- (UILabel *)rightTextL{
    if (_rightTextL == nil) {
        _rightTextL = [UILabel new];
        [self.contentView addSubview:_rightTextL];
        [_rightTextL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-35 * AUTO_WIDTH);
            make.height.mas_equalTo(15 * AUTO_HEIGHT);
            make.width.mas_equalTo(50 * AUTO_WIDTH);
            make.centerYWithinMargins.mas_equalTo(self.contentView);
            
        }];
        _rightTextL.textAlignment = NSTextAlignmentRight;
        _rightTextL.textColor = [UIColor blackColor];
       _rightTextL.font = [UIFont fontWithName:ZIXING size:13 * AUTO_WIDTH];        _rightTextL.text = @"www";
        _rightTextL.backgroundColor = [UIColor redColor];
        
    }
    return _rightTextL;
}


- (void)setType:(TYPE)type{
    if (_type != type) {
        _type = type;
    
    if (_type == TYPEA) {
        [self textL];//中间
    }
    if (_type == TYPEB) {//leftTitle + 星
        [self starImaegView];
    }
    if (_type == TYPEC){
        [self rightTextL];
    }
    
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
